<script type="text/javascript">
	var saved_charts = eval("{{saved_charts|escapejs}}")
	$('#select_all_user').click(function(){
		for (var i=0; i < saved_charts.length; i++){
			$('#'+saved_charts[i]).attr("checked","checked")
		}
	});
	$('#select_none_user').click(function(){
		for (var i=0; i < saved_charts.length; i++){
			$('#'+saved_charts[i]).removeAttr("checked")
		}
	});
	$('#delete_user').click(function(){
    	var selected_charts = []
    	for (var i=0; i < saved_charts.length; i++){
			if ($('#'+saved_charts[i]).is(":checked")){
				selected_charts.push(saved_charts[i])
			}
		}
    	$.ajax({
			type: "POST",
			url: '/pmp/utils/',
			data: JSON.stringify({'projectId': sessvars.sessionObj['projectId'], 'selected_charts':selected_charts}),
			success: function(data){
				$('#userCharts').html(data)
			}
		});	
	});
</script>
<form class="form-inline" id="chartsForm">
{% for chart in saved_charts %}
	<label class="checkbox"><input type="checkbox" id="{{chart}}" checked />{{chart}}</label>&nbsp;
{% endfor %}
&nbsp;&nbsp;<a href="#" id="select_all_user">Select all</a>
&nbsp;|&nbsp;<a href="#" id="select_none_user">Select none</a>
&nbsp;|&nbsp;<a href="#" id="delete_user">Delete selected</a>
</form>
